#ifndef BOYAA_DBPART_H_20090707
#define BOYAA_DBPART_H_20090707

#include <global.h>
#include <map>
#include <vector>
#include "def.h"
#include "baseDbPart.h"
#include "Singleton.h"
#include "1700_account.pb.h"
#include "currencymgr.h"


class CDbPart
{
public:
	CDbPart();
	virtual ~CDbPart();

public:
    static CDbPart* Instance()
	{
		return CSingleton<CDbPart>::Instance();
	}

public:
	// 查询用户uid
	bool GetUserId(const std::string& uuid, uint32& uid);
	// 注册用户基本信息
	bool RegisterNewPlayer(const std::string& uuid, const std::uint32_t uid, const std::string& agency, const std::string& username, const std::uint32_t agency_id);
	bool GetUserByUid(std::uint32_t uid, std::string& uuid, std::string& agency, std::string& username, std::uint32_t& agency_id);
	bool GetUserByUuid(const std::string& uuid, std::uint32_t& uid, std::string& agency, std::string& username, std::uint32_t& agency_id);

protected:
	// 字符串转整数
	bool StrToInt(const std::string& str, int& num);

public:
	//默认用户名
	std::string GetDefaultUname(uint32 uid) {return m_nDefaultUname + std::to_string(uid);}
	std::string SetDefaultUname(const std::string& uname) {return m_nDefaultUname = std::move(uname);}
	std::string m_nDefaultUname; //默认用户名

	// 头像
	std::int32_t GetAvatar(uint32 uid) { return uid % AVATAR_NUM; }

public:
	bool GetCurrency(stCurrency& st_currency);

public:
	CBaseDbPart* m_dbHandler;
	CBaseDbPart* m_agencyDb;
};
#endif
